﻿@model OrchestrationViewModel
@section ArtifactTitle {<span style="font-weight: normal;">Orchestration:</span> @Model.Orchestration.Name}
@{
    ViewBag.Title = "Orchestration";
    ViewBag.CurrentMenuItem = Model.CurrentApplication.Name;
    this.AddToViewBag(Model);
}
@if (!string.IsNullOrEmpty(Model.Orchestration.Description))
{
    <p class="description">@Model.Orchestration.Description</p>
}
<table cellpadding="0" cellspacing="0">
    <tr>
        <td>
            Application
        </td>
        <td>
            <a href="@Model.CurrentApplication.Path(Model.CurrentManifest)">@Model.CurrentApplication.Name</a>
        </td>
    </tr>
    <tr>
        <td>
            Parent Assembly
        </td>
        <td>
            <a href="@Model.Orchestration.ParentAssembly.Path(Model.CurrentManifest)">@Model.Orchestration.ParentAssembly.Name</a>
        </td>
    </tr>
    <tr>
        <td>
            Host
        </td>
        <td>
            @if (Model.Orchestration.Host != null)
            {
                @Model.Orchestration.Host.Name
            }
        </td>
    </tr>
</table>
<h3>
    Process overview
</h3>
<div class="section" style="">
    <div style="float: left; border: 1px solid #E5E5E5; padding: 5px;">
        <a target="_blank" href="@Model.Orchestration.SourcePath(Model.CurrentManifest)">
            <img alt="Orchestration overview" src="@Model.Orchestration.ThumbSourcePath(Model.CurrentManifest)" />
        </a>
    </div>
</div>
@if (Model.Orchestration.Ports.Cast<OrchestrationPort>().Where(op => op.ReceivePort != null).Count() > 0)
{
    <h3>
        Logical receive ports
    </h3>
    <table cellpadding="0" cellspacing="0">
        <tr>
            <th>
                Name
            </th>
            <th>
                Bound To
            </th>
        </tr>
        @foreach (var port in Model.Orchestration.Ports.Cast<OrchestrationPort>().Where(op => op.ReceivePort != null))
        {
            <tr>
                <td>
                    @port.ReceivePort.Name
                </td>
                <td>
                    <a href="@port.ReceivePort.Path(Model.CurrentManifest)">@port.Name</a>
                </td>
            </tr>
        }
    </table>
}
@if (Model.Orchestration.Ports.Cast<OrchestrationPort>().Where(op => op.SendPort != null).Count() > 0)
{
    <h3>
        Logical send ports
    </h3>
    <table cellpadding="0" cellspacing="0">
        <tr>
            <th>
                Name
            </th>
            <th>
                Bound To
            </th>
        </tr>
        @foreach (var port in Model.Orchestration.Ports.Cast<OrchestrationPort>().Where(op => op.SendPort != null))
        {
            <tr>
                <td>
                    @port.SendPort.Name
                </td>
                <td>
                    <a href="@port.SendPort.Path(Model.CurrentManifest)">@port.SendPort.Name</a>
                </td>
            </tr>
        }
    </table>
}
@section ManifestList {
    @Html.Partial("_ManifestListControl", new ManifestListModel() { Manifests = Model.Manifests, CurrentManifest = Model.CurrentManifest, Artefact = Model.Orchestration })
}
